<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>预约规则列表</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<section class="content-header">
		<h1>预约记录查看</h1>
		<ol class="breadcrumb">
			<li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
			<li class="active">药品招标管理</li>
            <li class="active">预约管理</li>
		</ol>
	</section>

	<section class="content">
		<div class=" box box-success">
			<div class="box-body">
				<div class=" form-inline">
					<!-- <div class="form-group form-group-xs">
						<label for="txtDrugName">预约日期：</label> 
						 <input style="width: 100px;" placeholder="预约日期" name="subscribeDate" id="subscribeDate" type="text"  value="" readonly="readonly" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" placeholder="yyyy-mm-dd">
					</div> -->
					<div class="form-group form-group-xs">
								<label for="txtDrugName" >预约日期：</label>
										<select id="subscribeDate" class="form-control">
										</select>
							</div>
						<button type="button" onclick="likeQuery();" class="btn btn-success btn-sm">查&nbsp;询</button>
				   </div>
			</div>
		</div>
		<table class="jqgrid" id="gridlist"></table>
		<div id="gridpage"></div>
		
		 <div class=" box box-warning bottongroup">
		 			<c:if test="${defalutProjId == null}">
		 				<button type="button" onclick="out();" class="btn btn-default btn-sm">打&nbsp;印</button>
		 				<button type="button" onclick="back();" class="btn btn-default btn-sm">返&nbsp;回</button>
		 			</c:if>
		 			<c:if test="${defalutProjId != null}">
		 			<button type="button" onclick="out();" class="btn btn-default btn-sm">打&nbsp;印</button>
		 				<button type="button" onclick="backDetail();" class="btn btn-default btn-sm">返&nbsp;回</button>
		 			</c:if>
                    
         </div>
		<form action="${ctx }/bidSubscribe/toSubscribeEditJsp.html" method="post" id="FormSubmit">
			<input type="hidden" id="bidSubscribeId" name="bidSubscribeId">
		</form>
		<form action="${ctx}/bidSubscribeRecord/toSuccessJsp.html" method="post" id="FormSuccess">
			<input type="hidden" id="bidSubscribeIdSuc" name="bidSubscribeId">
			<input type="hidden" id="subscribeDateSuc" name="subscribeDate">
			<input type="hidden" id="subscribeStarttime" name="subscribeStarttime">
			<input type="hidden" id="subscribeEndtime" name="subscribeEndtime">
			<input type="hidden" id="projNameSuc" name="projName">
		</form>
	</section>
   <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script src="${ctx}/lib/plugins/daterangepicker/moment.js"></script>
    <script src="${ctx}/lib/plugins/daterangepicker/daterangepicker.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#subscribeDate").HNSelect({
			    url: "${pageContext.request.contextPath}/selectController/getBidSubscribeDetailDate.html", data: { subscribeId : "${bidSubscribeId}" },defaultText: "<option value=''>请选择</option>",
			  });
			
			$("#gridlist").jqGrid({
								url : "getCompRecord.html",
								mtype : "POST",
								datatype : "json",
								postData : {"projId":"${projId}"},
								autowidth : true,
								height : 270,
								colNames : ['操作','Id','预约日期','预约时间','企业名称','状态','受理时间'],
								colModel : [
                                            {name : 'oper',width : 40,align : "center",sortable : false,
	                                            formatter : function(val, opts,rowdata) {
	                                              	if(rowdata.processStatus == 0 ){
		                                            	return "<a href=\"javascript:handle('"+rowdata.bidSubscribeRecordId+"');\">受理</a>";
	                                        	}
			                                    return "";
		
	                                           }
                                            },
											{name : 'bidSubscribeRecordId',width : 160,align : "center",hidden:true,sortable : false},
										    {name : 'subscribeDateStr',width : 160,align : "center",sortable : false},
										    {name : 'subTime',width : 160,align : "center",sortable : false,
										    	formatter : function(val, opts,
														rowdata) {
													return rowdata.subscribeStarttime+" - "+rowdata.subscribeEndtime;
											}	
										    },
										    {name : 'compName',width : 160,align : "center",sortable : false},
										    {name : 'processStatus',width : 80,align : "center",sortable : false,
										    	formatter : function(val, opts,rowdata) {
										    		if(rowdata.processStatus == 0 ){
										    			return "未受理";
										    		}
										    			return "已受理";
										    		
										    	}	
										    },
										    {name : 'processDatetime',width : 140,align : "center",sortable : false}
										    
										],
								rowNum : 20,
								rowList : [ 10, 20, 50,100 ],
								rownumbers : true,
								pager : "#gridpage",
								multiselect : false,
								viewrecords : true,
								caption : "${projName}",
								jsonReader : {
									repeatitems : false,
									id : "ids"
								}
							});
			$("#gridlist").jqGrid('navGrid', '#gridpage', {
				add : false,
				edit : false,
				del : false,
				search : false,
				refresh : false
			});

			 $(window).trigger("resize");
		});
		
		
		function lookJsp(dateStr,id,projName,startTime,endTime){
			$("#bidSubscribeIdSuc").val(id);
			$("#subscribeDateSuc").val(dateStr);
			$("#subscribeStarttime").val(startTime);
			$("#subscribeEndtime").val(endTime);
			$("#projNameSuc").val(projName);
			$("#FormSuccess").submit();
		}
		function likeQuery() {
			var subscribeDate = $("#subscribeDate").val();
			$("#gridlist").jqGrid('setGridParam',{
				       	    	datatype:'json',
				                postData:{
				                	"subscribeDate":subscribeDate
				                	},
				                page : 1
			}).trigger("reloadGrid");
		}
		
		
		
		  
		function back(){
	    	window.location.href="${ctx}/bidSubscribe/toSetSubProjListJsp.html";
	    }
		
		function backDetail(){
			window.location.href="${ctx}/bidSubscribe/toSubscribeDetailJsp.html?bidSubscribeId=${bidSubscribeId}&defalutProjId=${defalutProjId}";
		}	
		
		function handle(id){
		$.HN.message.confirm('确定要受理吗？', '', '').on(function (e) {
	       if (e) {
			$.ajax({
                url: "${pageContext.request.contextPath}/bidSubscribeRecord/updateRecord.html",//action地址
                data: { 
                	"bidSubscribeRecordId": id
                },//传值
                type: "post",//执行方式get or post 默认以post方式执行
                dataType:"json",
                success: function (result) {//执行成功后 提示
                	
                   if (result.success){
                	   $.alert('保存成功！', 'success');
                	   likeQuery();
                	   return;
                   } 
                },
                error: function () {// 如果执行出现错误 提示
                	$.alert('保存失败！', 'error');
                }
            });
		  }
		 });
		}
		
		 function out(){
	    	 window.print();
	    }
	</script>
</body>
</html>